package com.aaa.ssm.util;

import com.aaa.ssm.entity.Permission;

import java.util.ArrayList;
import java.util.List;

/**
 * @author lj
 * @date 2021/11/28 16:22
 */
public class PermissionUtil {
    public static List<Permission> handlePermission(List<Permission> commonPers){

        List<Permission> haha = new ArrayList<>();

        for(Permission commonPer :commonPers){
            String type=commonPer.getType();
            if ("M".equals(type)){
                haha.add(commonPer);
            }
        }
        for (Permission commonPer :commonPers){
            String type=commonPer.getType();
            if (!"M".equals(type)){
                for (Permission permission :haha){
                    Integer id1=permission.getId();
                    if (id1.equals(commonPer.getPid())){
                        permission.getSubMenu().add(commonPer);
                    }
                }
            }
        }
        return haha;
    }
}
